package com.xialuo.study.std;

import org.bsc.langgraph4j.serializer.Serializer;
import org.springframework.ai.chat.messages.ToolResponseMessage;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.List;

public class ToolResponseMessageSerializer implements Serializer<ToolResponseMessage> {

    @Override
    public void write(ToolResponseMessage object, ObjectOutput out) throws IOException {
        out.writeObject(object.getResponses());
    }

    @Override
    public ToolResponseMessage read(ObjectInput in) throws IOException, ClassNotFoundException {
        List<ToolResponseMessage.ToolResponse> toolResponses = (List<ToolResponseMessage.ToolResponse>)in.readObject();
        return new ToolResponseMessage(toolResponses);
    }
}
